package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Wards {
    private int wardsId;
    private String wardsName;
    private Integer wardsState;
    private Collection<Berths> berthsByWardsId;

    @Id
    @Column(name = "wards_id", nullable = false)
    public int getWardsId() {
        return wardsId;
    }

    public void setWardsId(int wardsId) {
        this.wardsId = wardsId;
    }

    @Basic
    @Column(name = "wards_name", nullable = true, length = 100)
    public String getWardsName() {
        return wardsName;
    }

    public void setWardsName(String wardsName) {
        this.wardsName = wardsName;
    }

    @Basic
    @Column(name = "wards_state", nullable = true)
    public Integer getWardsState() {
        return wardsState;
    }

    public void setWardsState(Integer wardsState) {
        this.wardsState = wardsState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Wards wards = (Wards) o;
        return wardsId == wards.wardsId &&
                Objects.equals(wardsName, wards.wardsName) &&
                Objects.equals(wardsState, wards.wardsState);
    }

    @Override
    public int hashCode() {
        return Objects.hash(wardsId, wardsName, wardsState);
    }

    @OneToMany(mappedBy = "wardsByWardsId")
    public Collection<Berths> getBerthsByWardsId() {
        return berthsByWardsId;
    }

    public void setBerthsByWardsId(Collection<Berths> berthsByWardsId) {
        this.berthsByWardsId = berthsByWardsId;
    }
}
